package com.dragon.mmochat.model.fuBen;

import java.io.Serializable;

import com.dragon.mmochat.model.MmochatSerial;
import com.dragon.mmochat.model.enumType.MmochatFuBenType;
import com.dragon.mmochat.model.gang.MmochatGang;
import com.dragon.mmochat.service.MmochatGangService;

//帮派副本
public class MmochatGangFuBen implements Serializable {
	private static final long serialVersionUID = 7915342965243655914L;
	private static MmochatSerial serial = new MmochatSerial();

	// 副本ID
	private int id;

	// 副本类型
	private MmochatFuBenType type;

	// 副本创建时间
	private long createTime = System.currentTimeMillis();

	// 副本存在时间
	private long lifeTime;

	// 帮派ID
	private int gangId;

	// 副本进度
	private int step = 1;

	// 副本难度
	private double hardParam = 1;

	// 副本线路
	private int line = 0;

	public MmochatGangFuBen() {
		id = serial.addAndGetSerialId();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public MmochatFuBenType getType() {
		return type;
	}

	public void setType(MmochatFuBenType type) {
		this.type = type;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public long getLifeTime() {
		return lifeTime;
	}

	public void setLifeTime(long lifeTime) {
		this.lifeTime = lifeTime;
	}

	public int getGangId() {
		return gangId;
	}

	public void setGangId(int gangId) {
		this.gangId = gangId;
	}
	
	public long getRestLife(){
		return lifeTime - (System.currentTimeMillis() - createTime);
	}

	public boolean isTimeOut() {
		return System.currentTimeMillis() - createTime >= lifeTime;
	}

	public void close() {
		MmochatGang gang = MmochatGangService.getGangById(gangId);
		if (gang != null) {
			gang.closeFuBen();
		}
	}

	public int getStep() {
		return step;
	}

	public void setStep(int step) {
		this.step = step;
	}

	public double getHardParam() {
		return hardParam;
	}

	public void setHardParam(double hardParam) {
		this.hardParam = hardParam;
	}

	public int getLine() {
		return line;
	}

	public void setLine(int line) {
		this.line = line;
	}

}
